# -*- encoding: utf8 -*-
import os
import datetime

class LogController:

    PathFile = ''
    def __init__( self , name ):
       
        self.PathFile = name+'.log'
        filearr = name.split('/')
        path,stip = "","/"
        for v in range(0,len(filearr)-1):
            path = path+stip+filearr[v]
        
        if not os.path.exists(path):
            os.mkdir(path)


        if not os.path.exists( self.PathFile ):
            fp = open( self.PathFile ,'w');
            fp.close()
        
    def writeLog( self , content ) : 
        
        nowTime = datetime.datetime.now()
        timestamp = str(nowTime.strftime('%Y-%m-%d %H:%M:%S'))
        content = timestamp + ":"+content + "\n" 
        fp = open( self.PathFile ,'a')
        fp.write(content)
        fp.close()
